/**getpid getppid fork*/
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main(void)
{
	printf("PID:%d,PPID:%d\n",getpid(),getppid());
//	while(1)
//		sleep(1);
	int a=100;
	int pid=fork();
	if(-1==pid){
		perror("fork error");
		return 1;
	}else if(!pid){
		printf("child pid:%d,parent pid:%d\n",getpid(),getppid());
		printf("hello world in child process\n");
		a=1000;
		printf("%d\n",a);
	}else{
		sleep(1);
		printf("father pid:%d,child pid:%d\n",getpid(),pid);
		printf("hello world in father process\n");
		printf("%d\n",a);
	}
	return 0;
}
